package com.itheima.collectionDemo;

import java.util.ArrayList;
import java.util.Iterator;

public class CollectionDemo7 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student("小皮同学", 23);
        Student s2 = new Student("小鹿同学", 31);
        Student s3 = new Student("小贾同学", 33);

        list.add(s1);
        list.add(s2);
        list.add(s3);

        Iterator<Student> iterator = list.iterator();
        while (iterator.hasNext()) {
            Student s = iterator.next();
            System.out.println(s);
        }

        System.out.println("--------------------------");

        for (Student student : list) {
            System.out.println(student);
        }
    }

}
